package com.aeon.thumbnail.ui;

import java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class ThumbnailDialog extends Dialog {

	public ThumbnailDialog(Shell parentShell) {
		super(parentShell);
		setShellStyle(SWT.RESIZE|SWT.CLOSE);
	}

	// @Override
	// protected Control createDialogArea(Composite parent) {
	//
	// ThumbnailControl control= new ThumbnailControl(parent, SWT.BORDER_SOLID);
	// control.setText("fsfdfhghfhgfhfgsf");
	// // control.setBackground(new Color(Display.getCurrent(), new RGB(20, 30,
	// 50)));
	// try {
	// control.setImage(ImageDescriptor.createFromURL(new
	// URL("file://E:/funPlace/swt/SWT/src/com/aeon/ui/label/img/music2.jpg")).createImage());
	// } catch (MalformedURLException e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	//
	// // Label label=new Label(parent, SWT.NONE);
	// // label.setText("dfjsf");
	// return super.createDialogArea(parent);
	// }

	@Override
	protected Control createDialogArea(Composite parent) {
		
		 
//		ScrolledComposite scrolledComposite=new ScrolledComposite(parent,SWT.V_SCROLL);
		
		 
		Composite composite=new Composite(parent,SWT.NONE);
		composite.setLayout(new GridLayout(3,false));
			createTumb(composite);
			createTumb(composite);
			createTumb(composite);
			
			createTumb(composite);
			createTumb(composite);
			createTumb(composite);

//			createbutton(composite);
//			createbutton(composite);
			
//			scrolledComposite.setContent(composite);
//			composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
			Control control= super.createDialogArea(parent);
		return control;	
	}

	
	
	private void createTumb(Composite parent) {
		Thumb control = new Thumb(parent, SWT.BORDER_SOLID);
		control.setSize(control.computeSize(10, 10));
		control.setAlignment(SWT.CENTER);
		control.setText("aaaaaaaaaaaaaaaaaaaaaaaaaa");
		control.setToolTipText("aaaaaaaaaaaaaaaaaaaaaaaaaa");
		try {
			control.setImage(ImageDescriptor
					.createFromURL(
							new URL(
									"file://E:/funPlace/swt/SWT/src/com/aeon/ui/label/img/music2.jpg"))
					.createImage());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

	private void createbutton(Composite parent) {
		Button control=new  Button(parent, SWT.FLAT|SWT.WRAP);
		
		control.setAlignment(SWT.CENTER);
		control.setText("aaaaaaaaaaaaaaaaaaaaaaaaaa");
		control.setToolTipText("aaaaaaaaaaaaaaaaaaaaaaaaaa");
		try {
			control.setImage(ImageDescriptor
					.createFromURL(
							new URL(
									"file://E:/funPlace/swt/SWT/src/com/aeon/ui/label/img/music2.jpg"))
					.createImage());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
}
